home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Tele / C / Calculator / Calc.src < prev    next >
Encoding:
Text File  |  1991-10-08  |  4.6 KB  |  210 lines  |  [TEXT/MWII]

  1. (    T.W.K's White Knight Calculator.               10/08/91 )
  2. (    My own small attempt at being clever. Written this past )
  3. ( week  while I was extreemly  bored. It is written entirely )
  4. ( in White Knightese, 'cept for ResEdit.                     )
  5. (    The  actual Calculator window,  resource ID = 9001, the )
  6. ( Help  and  About windows, resource ID's 9002, &  9003, are )
  7. ( contained  within this file.  If you are  unfamiliar  with )
  8. ( writing this type  of  procedure, you'll  need  ResEdit or )
  9. ( similiar utility,to open this file to see those resources. )
  10. ( If you find out how to work with non-integers,let me know. )
  11. (    I decided  not to go with a keypad,  which I started to )
  12. ( do, because this way,  you don't  need to  "MOUSE"  around )
  13. ( with a keypad on the screen,  you need only  a keyboard to )
  14. ( use this  procedure, and  it makes for alot less code this )
  15. ( way too.                                                   )
  16. (    You need to be in TTY  mode for the Print-to-Screen  to )
  17. ( work,  so your current emulation is checked,  then changed )
  18. ( to TTY,  and then restored to the previous mode.  The same )
  19. ( thing happends for your duplex setting.                    )
  20. ( * This is all free stuff, but if you are suddenly stricken )
  21. ( with gifted  insight by  all this,  please give me a small )
  22. ( plug  in  your  next freebe upload,  and in the mean time, )
  23. ( I'll promise to work on my modesty.                        )
  24.  
  25. ( Here we go;  First we clear all the variables that WE use, )
  26. ( that may have been set by another procedure.  )
  27. ERASE A$
  28. ERASE B$
  29. ERASE C$
  30. ERASE D$
  31. ERASE E$
  32.  
  33. ( Find out what emulation and duplex is set,  so we  can put )
  34. (    them back later. This is straight from my upload #1987. )
  35. ( >>>> Ouch! <<<<   I hurt my arm patting myself on my back. )
  36. GETGLOBAL F%,0
  37. GETGLOBAL G%,3
  38.  
  39. ( Now set duplex to null to avoid sending the text out the )
  40. (  modem and emulation to TTY.                             )
  41. COMM -NULL
  42. TTY
  43.  
  44. :START
  45.  
  46. SHELL A%,9001
  47.  
  48. (---------------- Quit button, #10, 'Pushed'? )
  49. TEST A% = 10
  50. IF YES JUMPTO RESTORE
  51.  
  52. (---------------- About button, #11 'Pushed'? )
  53. TEST A% = 11
  54. IF YES JUMPTO ABOUT
  55.  
  56. (---------------- Help button,  #2, 'Pushed'? )
  57. TEST A% = 2
  58. IF YES JUMPTO HELP
  59. IF NO JUMPTO SKIP
  60.  
  61. (---------------- Get the About box. )
  62. :ABOUT
  63. SHELL A%,9003
  64.  
  65. TEST A% = 1
  66. ( IMPRESSED! )
  67. IF YES JUMPTO START
  68.  
  69. TEST A% = 2
  70. ( Not impressed; do a bad Bill the cat impression & quit. )
  71. IF YES BELL
  72. TYPE Pthbbbb   
  73. BELL
  74. TYPE Pthbbbb   
  75. BELL
  76. TYPE Pthbbbb   
  77. BELL
  78. TYPE Pthbbbb   
  79. BELL
  80. TYPE Pthbbbb^M^M^M
  81. JUMPTO RESTORE
  82. (---------------- End About button. )
  83.  
  84. (---------------- Get the Help box. )
  85. :HELP
  86. SHELL A%,9002
  87.  
  88. TEST A% = 1
  89. IF YES JUMPTO START
  90. (---------------- End  Help button. )
  91.  
  92. :SKIP
  93.  
  94. ( Save the value of A$ into E$  so display looks correct. )
  95. COPYINTO E$,A$
  96.  
  97. ( string-$ / number-% )
  98. ( Translate  the  strings to numbers to do math function. )
  99. STRINGTONUM A$,A%
  100. STRINGTONUM C$,C%
  101.  
  102. ( Now  we have to figure out  what  operation to perform. )
  103. ( But first we have to convert +,-,*,/, into a NUMSTRING. )
  104. (   * is a decimal 42,  + is 43,  - is 45,  and  / is 47  )
  105. BYTEVAL B$,1,B%
  106.  
  107. ( :MULT --- We don't actully need a label here, so it's commented out. )
  108. TEST B% = 42
  109. IF NO JUMPTO ADD
  110. MULTIPLY A%,C%
  111. JUMPTO PRINT
  112.  
  113. :ADD
  114. TEST B% = 43
  115. IF NO JUMPTO SUBTR
  116. ADD A%,C%
  117. JUMPTO PRINT
  118.  
  119. :SUBTR
  120. TEST B% = 45
  121. IF NO JUMPTO DIV
  122. SUBTRACT A%,C%
  123. JUMPTO PRINT
  124.  
  125. :DIV
  126. TEST B% = 47
  127. IF NO JUMPTO ERROR
  128. DIVIDE A%,C%
  129. JUMPTO PRINT
  130.  
  131. :ERROR
  132. BELL
  133. TYPE Error... You must select Add(+) Subtract(-) Multiply(*) or Divide(/)^M
  134. COPYINTO D$,    Error!
  135. JUMPTO START
  136.  
  137. :PRINT
  138. TYPE A$
  139. TYPE ^M
  140. TYPE B$
  141. TYPE C$
  142. TYPE ^M
  143. TYPE _____________^M
  144.  
  145. ( Convert the answer to text and print. )
  146. NUMTOSTRING A%,A$
  147. TYPE A$
  148. TYPE ^M ^M ^M
  149.  
  150. ( Copy the answer to the bottom display, so the window looks OK. )
  151. COPYINTO D$,A$
  152. ( Now we correct the top display with the saved value in E$. )
  153. COPYINTO A$,E$
  154.  
  155. JUMPTO START
  156.  
  157. :RESTORE
  158. (-------> Start the terminal clean up. <-------)
  159. ( Check emulation... )
  160. TEST F% = 0
  161. IF NO JUMPTO ONE
  162. TTY
  163. JUMPTO DUPLEX
  164.  
  165. :ONE
  166. TEST F% = 1
  167. IF NO JUMPTO TWO
  168. VT100
  169. JUMPTO DUPLEX
  170.  
  171. :TWO
  172. TEST F% = 2
  173. IF NO JUMPTO THREE
  174. VT52
  175. JUMPTO DUPLEX
  176.  
  177. :THREE
  178. ( TEST F% = 3             since this is the last choice,
  179. ( IF NO JUMPTO FOUR       then VT102 must have been set,
  180. VT102
  181. ( JUMPTO DUPLEX           so we don't test F% for it.
  182.  
  183.  
  184. :DUPLEX
  185. ( Now we have to restore the original duplex setting. )
  186. ( If G% was  0:FULL or  1:HALF or  2:ECHO or  3:NULL. )
  187. TEST G% = 0
  188. IF NO JUMPTO HALF
  189. COMM -FULL
  190. END
  191.  
  192. :HALF
  193. TEST G% = 1
  194. IF NO JUMPTO ECHO
  195. COMM -HALF
  196. END
  197.  
  198. :ECHO
  199. TEST G% = 2
  200. IF NO JUMPTO NULL
  201. COMM -ECHO
  202. END
  203.  
  204. :NULL
  205. (No TEST or JUMPTO since this is the last choice)
  206. COMM -NULL
  207.  
  208. (-------> The end <-------)
  209. END
  210.